function SplitPage($rowCount, $QString = "", $limit=10) {
   global $GBL_CUR_PAGE, $GBL_PER_PAGE;

   $iPageCount = ceil($rowCount/$GBL_PER_PAGE);

   if ($QString == "" && isset ( $_SERVER ["QUERY_STRING"] )) $QString = "&".preg_replace("/page=(\d*)&{0,1}/", "", $_SERVER ["QUERY_STRING"]);

   $tempString = '<div class="ui pagination menu small">';
   $iStart = 1;
   $iEnd = $iPageCount;

   if ($iPageCount > $Loop) {
      $iStart = (ceil ( $GBL_CUR_PAGE / $Loop ) - 1) * $Loop + 1;
      $iEnd = (ceil ( $GBL_CUR_PAGE / $Loop )) * $Loop;
   }
   if ($iEnd > $iPageCount) $iEnd = $iPageCount;

   if ($GBL_CUR_PAGE == 1) {
      $tempString .= '<a class="icon disabled item"><i class="left arrow icon"></i></a>';
   } else {
      $tempString .= '<a class="icon item" href="'.$_SERVER ["PHP_SELF"]."?page=".($GBL_CUR_PAGE - 1).$QString .'"><i class="left arrow icon"></i> 上一页</a>';
   }

   for($i = $iStart; $i <= $iEnd; $i ++) {
      if ($i == $GBL_CUR_PAGE) {
         $tempString .= '<a class="active item" href="#"><b>'.$i.'</b></a>';
      } else {
         $tempString .= '<a class="item" href="'.$_SERVER ["PHP_SELF"]."?page=".$i.$QString.'">'.$i.'</a>';
      }
   }

   if ($GBL_CUR_PAGE == $iPageCount) {
      $tempString .= '<a class="icon disabled item"><i class="right arrow icon"></i></a>';
   } else {
      $tempString .= '<a class="icon item" href="'.$_SERVER ["PHP_SELF"]."?page=".($GBL_CUR_PAGE + 1).$QString.'"><i class="right arrow icon"></i> 下一页</a>';
   }

   $tempString .= "</div>";
   if ($iPageCount == 0)
      $tempString = '<div class="ui green message">没有任何记录.</div>';

   return $tempString;
}
function admin_pager($args=array())
{
   $total_rows = 0;
   $page_size = 10;
   $cur_page = 1;
   $base_url = '';

   extract($args);

   $return = array(
      'page_size'=>$page_size,
      'offset'=>0,
      'htm'=>'',
   );

   $total_pages = ceil($total_rows/$page_size);
   $cur_page < 1 && $cur_page = 1;
   $cur_page > $total_pages && $cur_page = $total_pages;

   if($total_rows == 0) return $return;

   $htm = '<nav>';
   $htm .= '<ul class="pagination">';

   $up = $cur_page - 1;
   $up <= 0 && $up = 1;
   $up_url = $base_url.'&page='.$up;
   $htm .= '<li><a href="'.$up_url.'" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>';

   $start = $cur_page - 4;
   $stop = $cur_page + 4;
   for($i=$start;$i<=$stop;$i++)
   {
      if($i > 0 && $i <= $total_pages){
         $active = $i==$cur_page ? 'active' : '';
         $page_url = $base_url.'&page='.$i;
         $htm .= '<li class="'.$active.'"><a href="'.$page_url.'">'.$i.'</a></li>';
      }
   }

   $down = $cur_page + 1;
   $down >= $total_pages && $down = $total_pages;
   $down_url = $base_url.'&page='.$down;
   $htm .= '<li><a href="'.$down_url.'" aria-label="Next"><span aria-hidden="true">&raquo;</span></li>';
   $htm .= "</ul>";
   $htm .= '</nav>';

   $return['offset'] = ($cur_page - 1) * $page_size;
   $return['htm'] = $htm;
   return $return;
}
